define(['egis'],
    function (egis) {
        Window.deserializer = Window.deserializer || new egis.core.Deserializer();
        Window.container = Window.container || {};
        dsBridge.register('create_FreeDrawTool', function (sourceId, commandId, layerId, elementId, content, activeCommandName) {
            var layer = Window.container[layerId];
            var element = Window.container[elementId];
            var jsonObj = Window.deserializer.createJsInstance(JSON.parse(content));
            element.geometry = jsonObj.geometry;
            element.symbol = jsonObj.symbol;
            var freeDrawTool = new egis.draw.FreeDrawTool({
                id: commandId,
                templateElement: element,
                drawLayer: layer,
                canContinue: false,
                isMouseDownDraw: true,
                activeCommandName: activeCommandName
            });
            freeDrawTool.onEndDraw = function (element) {
                Window.container[element.id] = element;
                dsBridge.call("egis.FreeDrawTool_onEndDraw", [sourceId, JSON.stringify(element)]);
            }
            Window.container[sourceId] = freeDrawTool;
        });

        dsBridge.register('FreeDrawTool_onClick', function (sourceId, param) {
            try {
                var freeDrawTool = Window.container[sourceId];
                if (!!freeDrawTool) {
                    freeDrawTool.onClick(param);
                }
            }
            catch (e) {
                alert(e)
            }
        });
    })